Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Conversation

@jaclync
Copy link
Contributor

@jaclync jaclync commented Jul 28, 2022

For woocommerce/woocommerce-ios#7318

Description

In order to track the source of invalid email errors for WCiOS local notifications experiment, we need a way to differentiate the two flows - "Enter Your Store Address" or "Continue With WordPress.com". This PR added a new SignInError and SignInSource and parsed the error for invalid email based on the WCiOS implementation.

WPiOS does not handle errors in a custom way like WCiOS.

Testing steps

Please refer to the WCiOS draft PR to test the integration.

Copy link
Contributor

@itsmeichigo itsmeichigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that the new error type is needed to avoid breaking changes (compared to updating the delegate method handleError with a new source parameter), and this works with the integration in Woo, so I'm approving this. Leaving a few nit-picking comments regarding the other case for source below though, please consider it if you think it makes sense.

Comment on lines -439 to -447
private func presentGetStartedView() {
guard let toVC = GetStartedViewController.instantiate(from: .getStarted) else {
DDLogError("Failed to navigate to GetStartedViewController")
return
}

navigationController?.pushViewController(toVC, animated: true)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why this is not needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to make a note on this, this is dead code 😅 I was checking where GetStartedViewController is initialized in WPAuthenticator, and thought it's good to remove any unused code.

Comment on lines 11 to 12
/// Other unspecified sources.
case other
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'm thinking this case is not really necessary, since we want to be as specific as possible in enums. If we want to avoid breaking changes, when integrating this library we could use @unknown default case to handle new cases in the future. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I think it makes sense to not include this default case and only errors with specific sources are passed to the client app. I made an update in 8591d33

// This is public so it can be set from StoredCredentialsAuthenticator.
var errorMessage: String?

var source: SignInSource = .other
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I suggested removing other case above, maybe we should keep source optional here 🤔.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 8591d33 👍

@jaclync
Copy link
Contributor Author

jaclync commented Jul 29, 2022

I understand that the new error type is needed to avoid breaking changes (compared to updating the delegate method handleError with a new source parameter), and this works with the integration in Woo, so I'm approving this.

Yes 😅 I was debating whether to make a breaking change for a better solution or a more implicit change with the error type as in this PR. Since we're on a tight schedule in Q3, I went with the latter one.

@jaclync jaclync merged commit 06fa1f6 into trunk Jul 29, 2022
@jaclync jaclync deleted the wcios/login-errors branch July 29, 2022 07:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants